package template;

import net.databinder.components.DataStyleLink;
import net.databinder.components.ao.DataForm;
import net.databinder.models.ao.EntityProvider;

import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.markup.repeater.data.IDataProvider;

public class Hello extends WebPage {
	
	/** Add components to be displayed on page.  */
	public Hello() {
		add(new DataStyleLink("css"));
		
		add (new InputForm("input"));
		
		IDataProvider provider = new EntityProvider(Datum.class);
		
		DataView data = new DataView("data", provider) {
			protected void populateItem(Item item) {
				item.add(new Label("text"));
			}
		};
		add(data);
	}
	
	public class InputForm extends DataForm {
		public InputForm(String id) {
			super(id, Datum.class);

			add(new TextField("text"));
		}
		@Override
		protected void afterSubmit() {
			getEntityModel().unbind();
		}
	}
}
